package defpackage; import android.support.v4.app.NotificationCompat; import android.text.TextUtils; import cn.wps.moffice.OfficeApp; import cn.wps.moffice.common.google.pay.sdk.Purchase; import cn.wps.moffice.extlibs.Qing3rdLoginConstants; import cn.wps.moffice_eng.R; import cn.wps.util.JSONUtil; import com.appsflyer.AppsFlyerProperties; import com.google.firebase.analytics.FirebaseAnalytics; import com.google.gson.reflect.TypeToken; import com.iflytek.cloud.SpeechConstant; import com.iflytek.cloud.SpeechEvent; import com.iflytek.cloud.SpeechUtility; import com.mopub.mobileads.VastExtensionXmlManager; import defpackage.dlv; import defpackage.vys; import defpackage.vyu; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TimeZone; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.scribe.model.OAuthConstants; /* renamed from: dnb reason: default package */ public final class dnb implements dna { private static final int[] dNk = {2, 5, 15}; private String dNi; private String dNj; private hwh dNl; private hwh dNm; dnb(boolean z) { if (z) { this.dNi = "http://54.223.135.152:93/v2/"; this.dNj = "http://54.223.135.152:93/v2/"; } else { this.dNi = "https://movip.wps.com/order/v2/"; this.dNj = "https://cloudservice23.kingsoft-office-service.com/v2/"; } this.dNl = hwi.AW(1); this.dNm = hwi.AW(2); } /* access modifiers changed from: private */ public static hwe a(String str, Purchase purchase, String str2) { hwe hwe = new hwe(true); String str3 = ""; try { str3 = String.valueOf(((TimeZone.getDefault().getRawOffset() / 60) / 60) / 1000); } catch (Exception e) { e.printStackTrace(); } hwe.dk("itemtype", purchase.getItemType()).dk("orderId", purchase.getOrderId()).dk("packageName", purchase.getPackageName()).dk("productId", purchase.getSku()).dk("purchaseTime", String.valueOf(purchase.getPurchaseTime())).dk("purchaseState", String.valueOf(purchase.getPurchaseState())).dk("developerPayload", purchase.getDeveloperPayload()).dk("purchaseToken", purchase.getToken()).dk("signature", purchase.getSignature()).dk("wpsid", str).dk("deviceId", OfficeApp.arx().arG()).dk(AppsFlyerProperties.CHANNEL, OfficeApp.arx().arB()).dk("zone", str3).dk("version", OfficeApp.arx().getResources().getString(R.string.app_version)).dk(FirebaseAnalytics.Param.SOURCE, str2).dk(SpeechConstant.LANGUAGE, eip.dHN); return hwe; } @Override // defpackage.dna public final vzu a(int i, String str, Purchase purchase, String str2, vyu.b<String> bVar, vyu.a aVar) { AnonymousClass3 r0 = new vzu(1, this.dNi + "buyTemplate", bVar, aVar, str, purchase, str2, i) { /* class defpackage.dnb.AnonymousClass3 */ final /* synthetic */ String dHp; final /* synthetic */ Purchase dLz; final /* synthetic */ String dMY; final /* synthetic */ int dNp; { this.dMY = r7; this.dLz = r8; this.dHp = r9; this.dNp = r10; } /* access modifiers changed from: protected */ @Override // defpackage.vys public final Map<String, String> awR() throws vyz { dnb dnb = dnb.this; hwe a = dnb.a((dnb) this.dMY, (String) this.dLz, (Purchase) this.dHp); a.dk("tid", String.valueOf(this.dNp)).dk(VastExtensionXmlManager.TYPE, dlv.a.template.name()); dnb.this.dNl.a(a); return a.cmr(); } }; r0.wDN = vys.a.HIGH; return r0; } @Override // defpackage.dna public final vzu a(dlw dlw, vyu.b<String> bVar, vyu.a aVar) { String str = this.dNi + "bind"; try { Purchase purchase = new Purchase(dlw.mItemType, dlw.mOriginalJson, dlw.mSignature); String str2 = TextUtils.isEmpty(dlw.dKM) ? "" : dlw.dKM; String str3 = TextUtils.isEmpty(dlw.dKN) ? "" : dlw.dKN; hwe a = a(str2, purchase, TextUtils.isEmpty(dlw.cBD) ? "" : dlw.cBD); a.dk("loginMode", str3).dk(VastExtensionXmlManager.TYPE, dlw.dKL); if (!TextUtils.isEmpty(dlw.dKO)) { a.dk("coupon_id", dlw.dKO); } this.dNl.a(a); new StringBuilder("upload purchase: ").append(a.cmq()); new StringBuilder("upload url: ").append(str); AnonymousClass2 r0 = new vzu(1, str, bVar, aVar, a) { /* class defpackage.dnb.AnonymousClass2 */ final /* synthetic */ hwe dNo; { this.dNo = r7; } /* access modifiers changed from: protected */ @Override // defpackage.vys public final Map<String, String> awR() throws vyz { return this.dNo.cmr(); } }; r0.wDN = vys.a.HIGH; return r0; } catch (JSONException e) { e.printStackTrace(); return null; } } @Override // defpackage.dna public final void a(dlw dlw) { String str; for (int i = 0; i < 3; i++) { try { Purchase purchase = new Purchase(dlw.mItemType, dlw.mOriginalJson, dlw.mSignature); String str2 = TextUtils.isEmpty(dlw.dKM) ? "" : dlw.dKM; String str3 = TextUtils.isEmpty(dlw.cBD) ? "" : dlw.cBD; try { str = String.valueOf(((TimeZone.getDefault().getRawOffset() / 60) / 60) / 1000); } catch (Exception e) { e.printStackTrace(); str = ""; } hwe hwe = new hwe(true); hwe.dk("itemType", purchase.getItemType()).dk("purchase", purchase.getOriginalJson()).dk(NotificationCompat.CATEGORY_EMAIL, str2).dk("deviceId", OfficeApp.arx().arG()).dk(AppsFlyerProperties.CHANNEL, OfficeApp.arx().arB()).dk("zone", str).dk("version", OfficeApp.arx().getResources().getString(R.string.app_version)).dk(FirebaseAnalytics.Param.SOURCE, str3).dk(SpeechConstant.LANGUAGE, eip.dHN); this.dNl.a(hwe); String a = dnd.a(this.dNj + "order", hwe.cmq(), hwe.bVz()); hwe.cmq(); if ("ok".equals(new JSONObject(a).getString(SpeechUtility.TAG_RESOURCE_RESULT))) { return; } } catch (Exception e2) { e2.printStackTrace(); } if (i < 2) { try { Thread.sleep((long) (dNk[i] * 1000)); } catch (InterruptedException e3) { return; } } } } @Override // defpackage.dna public final String ak(String str, String str2) throws Exception { hwe hwe = new hwe(true); hwe.dk("cdkey", str); hwe.dk("keyType", str2); hwe.dk("devid", eip.VID); hwe.dk("wpsid", ebo.bE(OfficeApp.arx())); hwe.dk("packageName", OfficeApp.arx().getPackageName()); hwe.dk(AppsFlyerProperties.CHANNEL, OfficeApp.arx().arA()); this.dNl.a(hwe); return lwd.z(lwd.d("https://movip.wps.com/order/v2/cdkeyBind2Wps", hwe.cmq(), null)); } @Override // defpackage.dna public final String al(String str, String str2) { if ("ads_free_i18n".equals(str)) { str = "ads_free"; } hwe hwe = new hwe(true); hwe.dk("uid", str2); hwe.dk("permitType", str); hwe.dk(SpeechConstant.LANGUAGE, eip.dHN); hwe.dk("version", OfficeApp.arx().getResources().getString(R.string.app_version)); hwe.dk(AppsFlyerProperties.CHANNEL, OfficeApp.arx().arB()); this.dNm.a(hwe); try { return lwd.f("https://movip.wps.com/template/permits/check?" + hwe.cmq(), null); } catch (Exception e) { e.printStackTrace(); return null; } } @Override // defpackage.dna public final List<dmu> kS(String str) throws Exception { ArrayList arrayList = new ArrayList(); hwe hwe = new hwe(true); hwe.dk("purchaseTokens", str); this.dNl.a(hwe); JSONArray jSONArray = new JSONArray(dnd.a(this.dNi + "checkTokensBind", hwe.cmq(), hwe.bVz())); for (int i = 0; i < jSONArray.length(); i++) { try { JSONObject jSONObject = jSONArray.getJSONObject(i); String string = jSONObject.getString("PurchaseToken"); String string2 = jSONObject.getString("Uid"); String optString = jSONObject.optString("LoginMode", Qing3rdLoginConstants.WPS_UTYPE); if (!TextUtils.isEmpty(string)) { dmu dmu = new dmu(); dmu.token = string; dmu.dML = string2; if (TextUtils.isEmpty(optString) || NotificationCompat.CATEGORY_EMAIL.equalsIgnoreCase(optString)) { optString = Qing3rdLoginConstants.WPS_UTYPE; } dmu.dMM = optString; arrayList.add(dmu); } } catch (Exception e) { e.printStackTrace(); } } return arrayList; } @Override // defpackage.dna public final List<Purchase> kT(String str) throws Exception { if (TextUtils.isEmpty(str)) { return null; } new StringBuilder("to pull purchase account : ").append(str); hwe hwe = new hwe(true); hwe.dk(NotificationCompat.CATEGORY_EMAIL, str); this.dNl.a(hwe); String f = lwd.f((this.dNi + "findOrder") + "?" + hwe.cmq(), null); new StringBuilder("to pull purchases info : ").append(f); ArrayList arrayList = new ArrayList(); JSONArray jSONArray = new JSONArray(f); for (int i = 0; i < jSONArray.length(); i++) { try { arrayList.add(new Purchase(jSONArray.get(i).toString())); } catch (Exception e) { e.printStackTrace(); } } return arrayList; } @Override // defpackage.dna public final List<dnc> kU(String str) throws Exception { if (TextUtils.isEmpty(str)) { return null; } new StringBuilder("to pull purchase account wpsid: ").append(str); hwe hwe = new hwe(true); hwe.dk("wpsid", str); this.dNl.a(hwe); String c = lwd.c(this.dNi + "checkWpsIdRecords", hwe.cmq(), null); new StringBuilder("to pull purchases info : ").append(c); return (ArrayList) JSONUtil.getGson().fromJson(c, new TypeToken<ArrayList<dnc>>() { /* class defpackage.dnb.AnonymousClass1 */ }.getType()); } @Override // defpackage.dna public final List<Purchase> kV(String str) { try { new StringBuilder("wpsId ").append(str); hwe hwe = new hwe(true); hwe.dk("uid", str); this.dNm.a(hwe); String f = lwd.f(hwe.BY("https://movip.wps.com/template/fontpack/query"), null); new StringBuilder("pull result: ").append(f); if (!TextUtils.isEmpty(f)) { ArrayList arrayList = new ArrayList(); JSONObject jSONObject = new JSONObject(f); if (!jSONObject.getString(SpeechUtility.TAG_RESOURCE_RESULT).equalsIgnoreCase("ok")) { return arrayList; } JSONArray jSONArray = new JSONArray(jSONObject.getString(SpeechEvent.KEY_EVENT_RECORD_DATA)); for (int i = 0; i < jSONArray.length(); i++) { String obj = jSONArray.get(i).toString(); if (!TextUtils.isEmpty(obj)) { arrayList.add(new Purchase(obj)); } } return arrayList; } } catch (Exception e) { e.printStackTrace(); } return null; } @Override // defpackage.dna public final String kW(String str) throws Exception { hwe hwe = new hwe(true); OfficeApp arx = OfficeApp.arx(); hwe.dk(OAuthConstants.CODE, str); hwe.dk("uid", ebo.bE(arx)); hwe.dk("version", arx.getString(R.string.app_version)); hwe.dk(AppsFlyerProperties.CHANNEL, OfficeApp.arx().arA()); hwe.dk("pchannel", OfficeApp.arx().arB()); hwe.dk(SpeechConstant.LANGUAGE, eip.dHN); hwe.dk("packageName", OfficeApp.arx().getPackageName()); hwe.dk("devid", eip.VID); this.dNm.a(hwe); return lwd.z(lwd.d("https://movip.wps.com/template/coupon/exchange", hwe.cmq(), null)); } }